package Servlet;

import DAO.MessageDAO;
import net.sf.json.JSONArray;
import pojo.Article;
import pojo.ArticleItem;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet(name= "UpdateArticleFieldValue",value = "/UpdateArticleFieldValue")
public class UpdateArticleFieldValue extends HttpServlet {
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setCharacterEncoding("UTF-8");
        MessageDAO messageDAO  = new MessageDAO();
        String articleID = request.getParameter("articleID");
        String articleFieldValue = request.getParameter("articleFieldValue");
        String operation = request.getParameter("operation");

        boolean ifUpdateSuccess = messageDAO.UpdateArticleFieldValue(articleFieldValue,articleID,operation);

        if(ifUpdateSuccess){
            response.getWriter().print("success");
        } else{

            response.getWriter().print("false");
        }
        response.getWriter().flush();
        response.getWriter().close();
    }

    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    }
}